package chipyard.fpga.vcu118

import scala.collection.immutable.HashMap

// TODO: was typed by hand, so this needs a once-over before it can be considered trustworthy

object FMCMap {
    // Take an FMC pin name and return the VCU118 package pin
    // See https://www.xilinx.com/support/documentation/boards_and_kits/vcu118/ug1224-vcu118-eval-bd.pdf
    // Pages 97-98
    // Omitted pins are not connected to a GPIO
    def apply(fmcPin: String): String = HashMap(
        "C10" -> "BD13",
        "C11" -> "BE13",
        "C14" -> "BB13",
        "C15" -> "BB12",
        "C18" -> "AW8",
        "C19" -> "AW7",
        "C22" -> "AP12",
        "C23" -> "AR12",
        "C26" -> "AL14",
        "C27" -> "AM14",
        "D1"  -> "AK35",
        "D8"  -> "BF10",
        "D9"  -> "BF9",
        "D11" -> "BE14",
        "D12" -> "BF14",
        "D14" -> "BA14",
        "D15" -> "BB14",
        "D17" -> "AY8",
        "D18" -> "AY7",
        "D20" -> "AR14",
        "D21" -> "AT14",
        "D23" -> "AN16",
        "D24" -> "AP16",
        "D26" -> "AK15",
        "D27" -> "AL15",
        "F1"  -> "BA7",
        "G2"  -> "AV14",
        "G3"  -> "AV13",
        "G6"  -> "AY9",
        "G7"  -> "BA9",
        "G9"  -> "BD12",
        "G10" -> "BE12",
        "G12" -> "BE15",
        "G13" -> "BF15",
        "G15" -> "BC14",
        "G16" -> "BC13",
        "G18" -> "AV9",
        "G19" -> "AV8",
        "G21" -> "AW11",
        "G22" -> "AY10",
        "G24" -> "AW13",
        "G25" -> "AY13",
        "G27" -> "AT12",
        "G28" -> "AU12",
        "G30" -> "AN15",
        "G31" -> "AP15",
        "G33" -> "AM13",
        "G34" -> "AM12",
        "G36" -> "AK14",
        "G37" -> "AK13",
        "H2"  -> "BB7",
        "H4"  -> "BC9",
        "H5"  -> "BC8",
        "H7"  -> "BC11",
        "H8"  -> "BD11",
        "H10" -> "BF12",
        "H11" -> "BF11",
        "H13" -> "BC15",
        "H14" -> "BD15",
        "H16" -> "BA16",
        "H17" -> "BA15",
        "H19" -> "BB16",
        "H20" -> "BC16",
        "H22" -> "AW12",
        "H23" -> "AY12",
        "H25" -> "AU11",
        "H26" -> "AV11",
        "H28" -> "AP13",
        "H29" -> "AR13",
        "H31" -> "AV10",
        "H32" -> "AW10",
        "H34" -> "AK12",
        "H35" -> "AL12",
        "H37" -> "AJ13",
        "H38" -> "AJ12"
    )(fmcPin)
}

object FMCPMap {
    // Take an FMC+ pin name and return the VCU118 package pin
    // See https://www.xilinx.com/support/documentation/boards_and_kits/vcu118/ug1224-vcu118-eval-bd.pdf
    // Pages 100-106
    // Omitted pins are not connected to a GPIO
    def apply(fmcpPin: String): String = HashMap(
        "A2"  -> "AN45",
        "A3"  -> "AN46",
        "A6"  -> "AL45",
        "A7"  -> "AL45",
        "A10" -> "AJ45",
        "A11" -> "AJ46",
        "A14" -> "W45",
        "A15" -> "W46",
        "A18" -> "U45",
        "A19" -> "U46",
        "A22" -> "AP42",
        "A23" -> "AP43",
        "A26" -> "AM42",
        "A27" -> "AM43",
        "A30" -> "AL40",
        "A31" -> "AL41",
        "A34" -> "T42",
        "A35" -> "T43",
        "A38" -> "P42",
        "A39" -> "P43",
        "B4"  -> "AF43",
        "B5"  -> "AF44",
        "B8"  -> "AG45",
        "B9"  -> "AG46",
        "B12" -> "N45",
        "B13" -> "N46",
        "B16" -> "R45",
        "B17" -> "R46",
        "B24" -> "AJ40",
        "B25" -> "AJ41",
        "B28" -> "AK42",
        "B29" -> "AK43",
        "B32" -> "K42",
        "B33" -> "K43",
        "B36" -> "M42",
        "B37" -> "M43",
        "C2"  -> "AT42",
        "C3"  -> "AT43",
        "C6"  -> "AR45",
        "C7"  -> "AR46",
        "C10" -> "AT35",
        "C11" -> "AT36",
        "C14" -> "AP35",
        "C15" -> "AR35",
        "C18" -> "AG31",
        "C19" -> "AH31",
        "C22" -> "R31",
        "C23" -> "P31",
        "C26" -> "V33",
        "C27" -> "V34",
        "D1"  -> "AK35",
        "D8"  -> "AL30",
        "D9"  -> "AL31",
        "D11" -> "AP38",
        "D12" -> "AR38",
        "D14" -> "AJ33",
        "D15" -> "AK33",
        "D17" -> "AJ35",
        "D18" -> "AJ36",
        "D20" -> "R34",
        "D21" -> "P34",
        "D23" -> "Y32",
        "D24" -> "W32",
        "D26" -> "V32",
        "D27" -> "U33",
        "E2" -> "V15",
        "E3" -> "U15",
        "E6" -> "R14",
        "E7" -> "P14",
        "E9" -> "W14",
        "E10" -> "V14",
        "E12" -> "V13",
        "E13" -> "U12",
        "E15" -> "T14",
        "E16" -> "R13",
        "E18" -> "M15",
        "E19" -> "L15",
        "F1" -> "AM34",
        "F4" -> "N14",
        "F5" -> "N13",
        "F7" -> "AA13",
        "F8" -> "Y13",
        "F10" -> "U11",
        "F11" -> "T11",
        "F13" -> "T16",
        "F14" -> "T15",
        "F16" -> "M13",
        "F17" -> "M12",
        "F19" -> "L14",
        "F20" -> "L13",
        "G2"  -> "P35",
        "G3"  -> "P36",
        "G6"  -> "AL35",
        "G7"  -> "AL36",
        "G9"  -> "AT39",
        "G10" -> "AT40",
        "G12" -> "AK29",
        "G13" -> "AK30",
        "G15" -> "AH33",
        "G16" -> "AH34",
        "G18" -> "AG34",
        "G19" -> "AH35",
        "G21" -> "N32",
        "G22" -> "M32",
        "G24" -> "N34",
        "G25" -> "N35",
        "G27" -> "Y34",
        "G28" -> "W34",
        "G30" -> "U35",
        "G31" -> "T36",
        "G33" -> "P37",
        "G34" -> "N37",
        "G36" -> "L34",
        "G37" -> "K34",
        "H2"  -> "AM33",
        "H4"  -> "AL32",
        "H5"  -> "AM32",
        "H7"  -> "AJ32",
        "H8"  -> "AK32",
        "H10" -> "AR37",
        "H11" -> "AT37",
        "H13" -> "AP36",
        "H14" -> "AP37",
        "H16" -> "AJ30",
        "H17" -> "AJ31",
        "H19" -> "AG32",
        "H20" -> "AG33",
        "H22" -> "N33",
        "H23" -> "M33",
        "H25" -> "M35",
        "H26" -> "L35",
        "H28" -> "T34",
        "H29" -> "T35",
        "H31" -> "M36",
        "H32" -> "L36",
        "H34" -> "N38",
        "H35" -> "M38",
        "H37" -> "L33",
        "H38" -> "K33",
        "J6"  -> "W12",
        "J7"  -> "V12",
        "J9"  -> "AA14",
        "J10" -> "Y14",
        "J12" -> "R12",
        "J13" -> "P12",
        "J15" -> "M11",
        "J16" -> "L11",
        "J18" -> "P15",
        "J19" -> "N15",
        "J21" -> "K12",
        "J22" -> "J12",
        "K7"  -> "AA12",
        "K8"  -> "Y12",
        "K10" -> "U13",
        "K11" -> "T13",
        "K13" -> "V16",
        "K14" -> "U16",
        "K16" -> "R11",
        "K17" -> "P11",
        "K19" -> "K14",
        "K20" -> "K13",
        "K22" -> "K11",
        "K23" -> "J11",
        "L4"  -> "R40",
        "L5"  -> "R41",
        "L8"  -> "AB38",
        "L9"  -> "AB39",
        "L12" -> "AF38",
        "L13" -> "AF39",
        "L16" -> "AN34",
        "L17" -> "AN35",
        "L20" -> "AN33",
        "L21" -> "AP33",
        "L24" -> "AK34",
        "L25" -> "AL34",
        "L28" -> "AM36",
        "L29" -> "AN36",
        "M2"  -> "AU45",
        "M3"  -> "AU46",
        "M6"  -> "AW45",
        "M7"  -> "AW46",
        "M10" -> "BA45",
        "M11" -> "BA46",
        "M14" -> "BC45",
        "M15" -> "BC46",
        "M18" -> "W40",
        "M19" -> "W41",
        "M22" -> "U40",
        "M23" -> "U41",
        "M26" -> "H42",
        "M27" -> "H43",
        "M30" -> "F42",
        "M31" -> "F43",
        "M34" -> "D42",
        "M35" -> "D43",
        "M38" -> "B42",
        "M39" -> "B43",
        "Y2"  -> "AV42",
        "Y3"  -> "AV43",
        "Y6"  -> "BB42",
        "Y7"  -> "BB43",
        "Y10" -> "AE45",
        "Y11" -> "AE46",
        "Y14" -> "AC45",
        "Y15" -> "AC46",
        "Y18" -> "AA45",
        "Y19" -> "AA46",
        "Y22" -> "Y43",
        "Y23" -> "Y44",
        "Y26" -> "AE40",
        "Y27" -> "AE41",
        "Y30" -> "AA40",
        "Y31" -> "AA41",
        "Y34" -> "J45",
        "Y35" -> "J46",
        "Y38" -> "E45",
        "Y39" -> "E46",
        "Z1"  -> "AM29",
        "Z4"  -> "AY42",
        "Z5"  -> "AY43",
        "Z8"  -> "BD42",
        "Z9"  -> "BD43",
        "Z12" -> "AD43",
        "Z13" -> "AD44",
        "Z16" -> "AB43",
        "Z17" -> "AB44",
        "Z20" -> "AN40",
        "Z21" -> "AN41",
        "Z24" -> "AG40",
        "Z25" -> "AG41",
        "Z28" -> "AC40",
        "Z29" -> "AC41",
        "Z32" -> "L45",
        "Z33" -> "L46",
        "Z36" -> "G45",
        "Z37" -> "G46"
    )(fmcpPin)
}
